<?php
$f = $this->form;
$hotelPrice = $this->hotelPrice;
?>
<div class="mainpage">
<form method="post" class="form-horizontal" enctype="multipart/form-data">
	<div class="top-tools">
        <?php echo $this->flashMessenger()?>
        <a href="/admin/hotel" class="exit  btn " ><i class="icon-hand-left hint" data-hint-msg="Quay lại"></i></a>

        <div class="pull-right">
            <?php echo $f->getDefaultActionGroup() ?>
        </div>
        <div class="clear"></div>
    </div>

    <div class="row-fluid">
    	<h3 class="form-legend"><?php echo $f->getLegend() ?></h3>
    </div>

    <div class="row-fluid">
        <div class="span12">
            <?php //echo $f ?>
            <!-- form add -->
            <?php
            echo $f->getElement('en_name');
            echo $f->getElement('name');
            echo $f->getElement('hotel_type_id');
            echo $f->getElement('hotel_type');
            echo $f->getElement('best_selling');
            echo $f->getElement('special_offer');
            echo $f->getElement('country_id');
            echo $f->getElement('region_id');
            echo $f->getElement('rating');
            echo $f->getElement('phone');
            echo $f->getElement('hotline');
            echo $f->getElement('fax');
            echo $f->getElement('email');
            echo $f->getElement('en_address');
            echo $f->getElement('address');
            echo $f->getElement('en_title');
            echo $f->getElement('title');
            echo $f->getElement('avatar');
            echo $f->getElement('thumbnail');
            ?>
            <div class="control-group">
                <label for="price" class="control-label required">Price </label>
                <div class="controls price">
                <!-- price table -->
                <table class="table tbl" border="1" style="width:60%;">
                    <thead>
                        <tr>
                            <th rowspan="2"><?php echo $this->translate('Room_catalogy'); ?></th>
                            <th colspan="3"><?php echo $this->translate('Room_rate/per_room/per_night_(USD)'); ?></th>
                            <th rowspan="2" colspan="2"><?php echo $this->translate('Validity').'<br/>(dd/mm/yyyy)'; ?></th>
                        </tr>
                        <tr>
                            <th><input name="single" value="Single"></th>
                            <th><input name="double" value="Double"></th>
                            <th><input name="extra-bed" value="Extra-bed"></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php if($hotelPrice): ?>
                            <?php foreach($hotelPrice as $key => $value):

                            if($value['validity_start'] != '' && Zend_Date::isDate($value['validity_start'], 'yyyy-MM-dd')) {
                                $validityStartOject  = new Zend_Date($value['validity_start'], 'dd/MM/yyyy');
                                $validityStart       = $validityStartOject->toString('yyyy-MM-dd');
                            } else {
                                $validityStart = '';
                            }
                            if($value['validity_end'] != '' && Zend_Date::isDate($value['validity_end'], 'yyyy-MM-dd')) {
                                $validityEndOject = new Zend_Date($value['validity_end'], 'dd/MM/yyyy');
                                $validityEnd      = $validityEndOject->toString('yyyy-MM-dd');
                            } else {
                                $validityEnd = '';
                            }



                            ?>
                            <tr>
                                <td  style="text-align:left"><input type="text" name="room_catalogy[]" value="<?php echo $value['room_catalogy'] ?>" style="width:auto;text-align:left"></td>
                                <td><input name="single[]" value="<?php echo $value['single']; ?>"></td>
                                <td><input name="double[]" value="<?php echo $value['double']; ?>"></td>
                                <td><input name="extra-bed[]" value="<?php echo $value['extra-bed']; ?>"></td>
                                <td><input name="validity_start[]" value="<?php echo $validityStart; ?>"></td>
                                <td><input name="validity_end[]" value="<?php echo $validityEnd; ?>"></td>
                            </tr>
                            <?php endforeach; ?>
                        <?php else: ?>
                        <?php for($i = 0; $i < 5; $i++): ?>
                            <tr>
                                <td><input type="text" name="room_catalogy[]" style="width:auto;text-align:left"></td>
                                <td><input name="single[]" class="hint" title="Số tiền"></td>
                                <td><input name="double[]"></td>
                                <td><input name="extra-bed[]"></td>
                                <td><input name="validity_start[]"></td>
                                <td><input name="validity_end[]"></td>
                            </tr>
                        <?php endfor; ?>
                        <?php endif; ?>
                        <tr class="more_price" style="display:none">
                            <td><input type="text" name="room_catalogy[]" style="width:auto;text-align:left"></td>
                            <td><input name="single[]"></td>
                            <td><input name="double[]"></td>
                            <td><input name="extra-bed[]"></td>
                            <td><input name="validity_start[]"></td>
                            <td><input name="validity_end[]"></td>
                        </tr>
                        <tr>
                            <td colspan="8"><input type="button" class="btn btn-primary" style="width:auto;margin:10px" name="add_more_price" id="add_more_price" value="Add more"></td>
                        </tr>
                    </tbody>
                </table>
                <!-- end price table -->
                </div>
            </div>
            <?php
            echo $f->getElement('en_overview');
            echo $f->getElement('overview');
            echo $f->getElement('en_itinerary');
            echo $f->getElement('itinerary');
            echo $f->getElement('en_detail');
            echo $f->getElement('detail');
            echo $f->getElement('meta_keyword');
            echo $f->getElement('meta_description');
            echo $f->getElement('header_title');
            ?>
            <div class="form-action-group">
                <input type="submit" name="submit" id="submit" value="Save" class="btn btn-primary">
                <input type="reset" name="reset" id="reset" value="Reset" class="btn">
            </div>
            <!-- end form add -->
        </div>
    </div>

    <div class="clear"></div>
</form>
</div>


<style>
.price input {
	width: 80px;
	text-align: center;
	border: none;
	webkit-border-radius: none;
    -moz-border-radius: none;
    border-radius: none;
}
.price select{
	width: 70px;
}

.price .table th, .table td {
	padding: 0px;
}

.price .table tr{
	min-height: 20px;
}
.price .table thead th {
    vertical-align: middle;
}
</style>

<script>
$(document).ready(function() {
    $('#add_more_price').click(function() {
    	(t = $('.more_price')).clone().removeClass('more_price').show().insertBefore(t);
        }
    );
});
</script>